from app.gnn.graph_builder import build_graph
from app.gnn.gnn_model import GNNMessagePassing
import torch

model = GNNMessagePassing()
model.eval()   # 空训练→用随机权重先跑逻辑

def gnn_signal():
    x, edge_index, node_idx = build_graph()
    if x is None:
        return {}
    with torch.no_grad():
        score = model(x, edge_index).squeeze().numpy()
    # 只取股票节点
    stocks = {k: float(score[i]) for k, i in node_idx.items() if k.startswith(('sz', 'sh'))}
    return stocks
